// pages/name/name.js
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
	http:getApp().globalData.map
	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	onShow: function(options) {
		wx.getStorage({
			key: 'uid',
			success: (e) => {
				console.log(e)
				wx.request({
					url: getApp().globalData.xc,
					method: "POST",
					header: {
						"Content-Type": "application/x-www-form-urlencoded"
					},
					data: {
						HTTP_API: 'vv/sync/api/index/user',
						user_id:e.data.uid,
						login_token:e.data.uid,
						nickname:e.data.nick_name,
						avatar:this.data.http+e.data.avatar,
						mobile:e.data.mobile
					},
					success:(e)=>{
						console.log(e)
						this.setData({
							banner:e.data.data.list
						})
					}
				})
				wx.request({
					url: getApp().globalData.xc,
					method: "POST",
					header: {
						"Content-Type": "application/x-www-form-urlencoded"
					},
					data: {
						HTTP_API: 'vv/banner/api/index/getBannerByTypeKeyName',
						keyname:'user',
						token:e.data.uid
					},
					success:(e)=>{
						console.log(e)
						this.setData({
							banner:e.data.data.list
						})
					}
				})
				wx.request({
					url: getApp().globalData.xc,
					method: "POST",
					header: {
						"Content-Type": "application/x-www-form-urlencoded"
					},
					data: {
						HTTP_API: 'vv/usercenter/api/user/profile',
						token:e.data.uid
					},
					success:(e)=>{
						console.log(e)
						this.setData({
							data:e.data.data.userinfo
						})
					}
				})
			},
			fail:(e)=>{
				wx.redirectTo({
					url:'../../register/register'
				})
			}
		})
	},
})
